$(document).ready(function(){
  $(".votePosComment").live('click',function(){
    var linkid=$(this).parent().parent().parent().attr('id').toString().split('-')[1];
    voteComment(linkid,1);
  });
  
  $(".voteNegComment").live('click',function(){
    var linkid=$(this).parent().parent().parent().attr('id').toString().split('-')[1];
    voteComment(linkid,-1);
  });
});

function voteComment(commentid,vote_val){
  $.ajax({
    type: 'POST',
    url: DO_COMMENT_VOTE_URL,
    data: { value: vote_val, id: commentid },
    success: function(data){
      if(data.error){
        alert(data.error);
      }else{
        var sel='#comment-'+data.Comment.id+' .comment-meta .comment-karma';
        $(sel).html('karma '+data.Comment.karma+', votes '+data.Comment.votes);
      }
    },
    dataType: 'json'  
  });
}